﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using Vigenere.Models;

namespace Vignere
{
    public partial class frmMain : Form
    {
        public frmMain()
        {
            InitializeComponent();
        }

        private void frmMain_Load(object sender, EventArgs e)
        {

        }

        private void textBox1_TextChanged(object sender, EventArgs e)
        {

        }

        private void lblPlain_Click(object sender, EventArgs e)
        {
            
        }

        private void lblKey_Click(object sender, EventArgs e)
        {
            
        }

        private void Encode_Click(object sender, EventArgs e)
        {
            List<int> Key = new List<int>();
            List<int> Plain = new List<int>();
            List<int> Cipher = new List<int>();
            List<char> Ciphertext = new List<char>();
            Encode encode = new Encode();
            MyEncode myEncode = new MyEncode();
            myEncode.PlainInput = txtPlain.Text;
            myEncode.KeyInput = txtKey.Text;
            encode.ToNum(Key, Plain, myEncode.KeyInput, myEncode.PlainInput);        //将原文和密钥转为数字
            encode.Vigenerefun(myEncode, Key, Plain, Cipher, Ciphertext);           //加密函数
        }

        private void lblCiphertext_Click(object sender, EventArgs e)
        {
            
        }

        private void button1_Click(object sender, EventArgs e)
        {

        }

        private void btnCiphertext_Click(object sender, EventArgs e)
        {
            List<int> Key = new List<int>();
            List<int> Plain = new List<int>();
            List<int> Cipher = new List<int>();
            List<char> Ciphertext = new List<char>();
            Encode encode = new Encode();
            MyEncode myEncode = new MyEncode();
            myEncode.PlainInput = txtPlain.Text;
            myEncode.KeyInput = txtKey.Text;
            encode.ToNum(Key, Plain, myEncode.KeyInput, myEncode.PlainInput);        //将原文和密钥转为数字
            txtCiphertext.Text=Convert.ToString(encode.Vigenerefun(myEncode, Key, Plain, Cipher, Ciphertext));           //加密函数
            

        }
    }
}
